#!/usr/bin/env python
# encoding: utf-8
# Date: 2017-06-19 09:04:25
# file:models.py
# Email: wang521kang@outlook.com
# Author: 王康
import datetime
from django.conf import settings
from django.db import models

from address.models import Address
from commodity.models import Commodity


class Person(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    name = models.CharField(max_length=255, verbose_name=u'姓名')
    phone = models.IntegerField(null=True, verbose_name=u'电话')


class Order(models.Model):
    Not_Pay = 0
    Pay = 1
    Over = 2
    Order_Status = (
        (Not_Pay, u'未付款'),
        (Pay, u'已付款'),
        (Over, u'已完成'),
    )
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    status = models.IntegerField(default=0, choices=Order_Status, verbose_name=u'状态')
    create_time = models.DateTimeField(default=datetime.datetime.now, verbose_name=u'创建时间')
    is_active = models.BooleanField(default=True, verbose_name=u'是否已删除')
    name = models.CharField(max_length=255, null=True, verbose_name=u'收货人')
    phone = models.CharField(max_length=255, null=True, verbose_name=u'电话')
    add_province = models.CharField(max_length=255, null=True, verbose_name=u'省地址')
    add_city = models.CharField(max_length=255, null=True, verbose_name=u'市地址')
    add_district = models.CharField(max_length=255, null=True, verbose_name=u'区地址')
    add_detail = models.CharField(max_length=255, null=True, verbose_name=u'详细地址')


class OrderCommodity(models.Model):
    commodity = models.ForeignKey(Commodity, verbose_name=u'商品主键')
    price = models.CharField(max_length=255, verbose_name=u'商品价格')
    num = models.CharField(max_length=255, verbose_name=u'商品数量')
    order = models.ForeignKey(Order, verbose_name=u'订单主键')
